#include <iostream>
#include <queue>
using namespace std;

struct mem{
	int k,s;
	bool operator < (const mem x)const{
		if(s == x.s)
			return k>x.k;
		return s<x.s;
	}
};

int main(){
	int n,m;
	cin>>n>>m;
	m = m*1.5;
	mem a[n];
	priority_queue<mem> q;
	for(int i=0;i<n;i++){
		mem l;
		cin>>l.k;
		cin>>l.s;
		q.push(l);
	}
	for(int i=0;i<m;i++){
		a[i] = q.top();
		q.pop();
		if(i == m-1  &&  a[i].s == q.top().s)
			m++;
	}
	cout<<a[m-1].s<<" "<<m<<endl;
	for(int i=0;i<m;i++)
		cout<<a[i].k<<" "<<a[i].s<<endl;
	return 0;
}
